package com.dog.basics.api.controller.mtkj;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.dog.basics.bean.dto.api.mtkj.ApiShopGoodTypeAddDto;
import com.dog.basics.bean.dto.api.mtkj.ApiShopGoodTypeEditDto;
import com.dog.basics.bean.vo.api.mtkj.ApiShopGoodsTypeVo;
import com.dog.basics.common.constant.SwaggerConstants;
import com.dog.basics.common.util.PageParam;
import com.dog.basics.common.util.R;
import com.dog.basics.security.annotation.Inner;
import com.dog.basics.service.mtkj.IMtShopGoodTypeService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;

/**
 * <p>
 * 店铺商品类型表 前端控制器
 * </p>
 *
 * @author wph
 * @since 2020-11-09
 */
@Api(value = "店铺商品类型",tags = SwaggerConstants.API_ALL)
@RestController
@RequestMapping("/api/shopGoodType")
@AllArgsConstructor
public class MtShopGoodTypeController {

    private final IMtShopGoodTypeService shopGoodTypeService;


    /**
     * 查询店铺商品类型列表
     *      分局商铺id查
     * @param: shopId  商铺id
     * @returns 
     * @author hangdy
     * @date: 2020/11/12 12:26
     */ 
    @GetMapping("findAll/{shopId}")
    @ApiOperation(value = "查询店铺商品类型列表", notes = "店铺商品类型列表",tags = SwaggerConstants.API_SHOPPING_GOOD_TYPE)
    @ApiImplicitParam(value = "商铺Id", name = "shopId", dataType = "Long", required = true)
    @Inner
    public R<IPage<ApiShopGoodsTypeVo>> findAllByShopId(PageParam page, @Valid @PathVariable("shopId")Long shopId){
        return R.ok(shopGoodTypeService.findAllByShopId(page,shopId));
    }

    /**
     * 增加店铺商品类型
     * @param obj
     * @return
     * @author hangdy
     */

    @ApiOperation(value = "增加店铺商品类型", notes = "增加店铺商品类型", tags = SwaggerConstants.API_SHOPPING_GOOD_TYPE)
    @PostMapping("/save")
    @Inner
    public R<Boolean> save(@Valid @RequestBody ApiShopGoodTypeAddDto obj) {
        return R.ok(shopGoodTypeService.saveShopGoodType(obj));
    }

    /**
     * 更新店铺商品类型
     * @param obj
     * @return
     * @author hangdy
     */

    @ApiOperation(value = "更新店铺商品类型", notes = "更新店铺商品类型",tags = SwaggerConstants.API_SHOPPING_GOOD_TYPE)
    @PutMapping("/edit")
    @Inner
    public R<Boolean> edit(@Valid @RequestBody ApiShopGoodTypeEditDto obj) {
        return R.ok(shopGoodTypeService.editShopGoodType(obj));
    }

    /**
     * 删除店铺商品类型
     * @param id
     * @return
     * @author hangdy
     */

    @ApiOperation(value = "删除店铺商品类型", notes = "删除店铺商品类型",tags = SwaggerConstants.API_SHOPPING_GOOD_TYPE)
    @ApiImplicitParam(value = "店铺商品类型Id", name = "id", dataType = "Long", required = true)
    @DeleteMapping("/delete/{id}")
    @Inner
    public R<Boolean> delete(@Valid @PathVariable("id") Long id) {
        return R.ok(shopGoodTypeService.deleteGoodType(id));
    }

}
